word = input()
a = set(word)
a = list(a)
b = {}

for i in a:
    b[i] = b.get(i, 0) + word.count(i)
sorted_b = dict(sorted(b.items(), key = lambda x: (-x[1], x[0])))

print(list(sorted_b.keys())[0])
print(list(sorted_b.values())[0])
